package cn.apestar.modules.sys.component;

import java.util.ArrayList;
import java.util.List;

import cn.apestar.common.utils.tran.TransLateCondition;
import cn.apestar.common.utils.tran.TranslateUtil;
import cn.apestar.modules.sys.entity.Institution;

public class InstitutionDataCovert {

    // 初始化翻译数据
    public static List initTranslate() {
        List list = new ArrayList();
        // 省
        list.add(new TransLateCondition("province", "sys_area a", "a.name as shengName", "id"));
        // 市
        list.add(new TransLateCondition("city", "sys_area a", "a.name as cityName", "id"));
        // 县
        list.add(new TransLateCondition("county", "sys_area a", "a.name as xianName", "id"));
        // 学校
        // list.add(new TransLateCondition("schoolId", "school a", "a.school_name as schoolName", "id"));
        return list;
    }

    /**
     * 翻译单个人员
     */
    public static Institution translateInstitution(Institution u) {
        List listHTranslate = initTranslate();
        for (int i = 0; i < listHTranslate.size(); i++) {
            TransLateCondition t = (TransLateCondition) listHTranslate.get(i);
            TranslateUtil.t.translateListT(u, t, true);
        }
        return u;
    }

    /**
     * 翻译人员集合
     */
    public static List<Institution> translateListInstitution(List<Institution> list) {
        List listHTranslate = initTranslate();
        for (int i = 0; i < listHTranslate.size(); i++) {
            TransLateCondition t = (TransLateCondition) listHTranslate.get(i);
            TranslateUtil.t.translateList(list, t, true);
        }
        return list;
    }

}
